package org.application;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

//import com.tencent.bugly.crashreport.CrashReport;
import com.example.sunmiv1.room.BaseApp;
import com.zhy.autolayout.BuildConfig;
import com.zhy.autolayout.config.AutoLayoutConifg;

import net.nyx.printerservice.print.DeviceServiceChannel;

import org.xprinter.XprinterManager;

import java.util.LinkedList;
import java.util.List;


/**
 * Created by Administrator on 2018-05-12.
 */

public class ClientApplication extends Application {

    public static Context context;
    public static boolean isPrint= BuildConfig.DEBUG?false:true;

    private static List<Activity> list = new LinkedList<>();

    /*    public boolean isAidl() {
            return isAidl;
        }

        public void setAidl(boolean aidl) {
            isAidl = aidl;
        }*/

    public static Context getContext() {
        return context;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        BaseApp.INSTANCE.onCreate(this);
        AutoLayoutConifg.getInstance().useDeviceSize().updateDesignSize(0,0)
            .init(this);
        // printUtil.getInstance().initPrinter();
        //  CrashReport.initCrashReport(getApplicationContext(), "e7f3c0d215", true);

        //isAidl = true;
        //N80 打印模块AIDEL
        DeviceServiceChannel.getInstance().bindRemoteServiceTask(context);
        //连接 标签打印设备SDK
        XprinterManager.getInstance().initXprinterSdk(this);

        //printUtil.getInstance().connectPrinterService(context);
//        initUniversalImageLoader();
    }

    public static void saveActivity(Activity activity) {
        list.add(activity);
    }

    public static void finishActivity() {
        for (Activity activity : list) {
        if (activity != null) {
            activity.finish();
        }
    }
    }

}
